<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<h1 class="red">Hello JSP</h1>
<h1 class="red">ABC ${sessionScope.test}</h1>
<h1 class="red">ABCDEF ${sessionScope["test"]}</h1>
<c:if test="${sessionScope['test'] != null}">
    <a href="javascript:;" onclick="logout()">退出</a>
    <h1 class="red">session test not null</h1>
    <script>
        function logout() {
            //步骤一:创建异步对象
            var ajax = new XMLHttpRequest();
            //步骤二:设置请求的url参数,参数一是请求的类型,参数二是请求的url,可以带参数,动态的传递参数starName到服务端
            ajax.open('get','/mytest/logout');
            //步骤三:发送请求
            ajax.send();
            //步骤四:注册事件 onreadystatechange 状态改变就会调用
            ajax.onreadystatechange = function () {
                if (ajax.readyState==4 &&ajax.status==200) {
                    //步骤五 如果能够进到这个判断 说明 数据 完美的回来了,并且请求的页面是存在的
                    //console.log(ajax.responseText);//输入相应的内容
                    window.location.href = "http://www.all-share.com.cn/index.php/Home/News/index/abc/5.html";
                }
            }
        }
    </script>
</c:if>